// 《围棋》作者版权所有。版权所有。
// 此源代码的使用受BSD样式
// 许可证的约束，该许可证可以在许可证文件中找到。

// 开始：构建openbsd&！mips64 
// /+构建openbsd，！mips64 

package runtime

import "unsafe"

// 这是在运行时/cgo中通过linkname导出到程序集的。
// go:linkname退出
// go:nosplit 
// go:cgo\u unsafe\u args 
func exit(code int32) {
	libcCall(unsafe.Pointer(funcPC(exit_trampoline)), unsafe.Pointer(&code))
}
func exit_trampoline()

// go:nosplit 
// go cgo\u unsafe\u args 
func getthrid() (tid int32) {
	libcCall(unsafe.Pointer(funcPC(getthrid_trampoline)), unsafe.Pointer(&tid))
	return
}
func getthrid_trampoline()

// go nosplit 
// go cgo\u unsafe\u args 
func raiseproc(sig uint32) {
	libcCall(unsafe.Pointer(funcPC(raiseproc_trampoline)), unsafe.Pointer(&sig))
}
func raiseproc_trampoline()

// go nosplit 
func thrkill(tid int32, sig int) {
	libcCall(unsafe.Pointer(funcPC(thrkill_trampoline)), unsafe.Pointer(&tid))
}
func thrkill_trampoline()

// 拆分，因为此函数（由sysAlloc使用）在运行时的许多低级
// 部分调用，调用方通常认为它不会获得任何锁。go:nosplit 
// go:nosplit 
func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (unsafe.Pointer, int) {
	args := struct {
		addr            unsafe.Pointer
		n               uintptr
		prot, flags, fd int32
		off             uint32
		ret1            unsafe.Pointer
		ret2            int
	}{addr, n, prot, flags, fd, off, nil, 0}
	libcCall(unsafe.Pointer(funcPC(mmap_trampoline)), unsafe.Pointer(&args))
	return args.ret1, args.ret2
}
func mmap_trampoline()

// go:nosplit 
// go:cgo\u unsafe\u args 
func munmap(addr unsafe.Pointer, n uintptr) {
	libcCall(unsafe.Pointer(funcPC(munmap_trampoline)), unsafe.Pointer(&addr))
}
func munmap_trampoline()

// go:nosplit 
// go:cgo\u unsafe\u args 
func madvise(addr unsafe.Pointer, n uintptr, flags int32) {
	libcCall(unsafe.Pointer(funcPC(madvise_trampoline)), unsafe.Pointer(&addr))
}
func madvise_trampoline()

// go:nosplit 
// go:cgo\u unsafe\u args 
func open(name *byte, mode, perm int32) (ret int32) {
	return libcCall(unsafe.Pointer(funcPC(open_trampoline)), unsafe.Pointer(&name))
}
func open_trampoline()

// go:nosplit 
func closefd(fd int32) int32 {
	return libcCall(unsafe.Pointer(funcPC(close_trampoline)), unsafe.Pointer(&fd))
}
func close_trampoline()

// go:cgo不安全参数
func read(fd int32, p unsafe.Pointer, n int32) int32 {
	return libcCall(unsafe.Pointer(funcPC(read_trampoline)), unsafe.Pointer(&fd))
}
func read_trampoline()

// go:nosplit 
// go:cgo不安全参数
func write1(fd uintptr, p unsafe.Pointer, n int32) int32 {
	return libcCall(unsafe.Pointer(funcPC(write_trampoline)), unsafe.Pointer(&fd))
}
func write_trampoline()

func pipe() (r, w int32, errno int32) {
	return pipe2(0)
}

func pipe2(flags int32) (r, w int32, errno int32) {
	var p [2]int32
	args := struct {
		p     unsafe.Pointer
		flags int32
	}{noescape(unsafe.Pointer(&p)), flags}
	errno = libcCall(unsafe.Pointer(funcPC(pipe2_trampoline)), unsafe.Pointer(&args))
	return p[0], p[1], errno
}
func pipe2_trampoline()

// go:nosplit 
// go:cgo不安全参数
func setitimer(mode int32, new, old *itimerval) {
	libcCall(unsafe.Pointer(funcPC(setitimer_trampoline)), unsafe.Pointer(&mode))
}
func setitimer_trampoline()

// go nosplit 
// go go cgo:cgo不安全参数
func usleep(usec uint32) {
	libcCall(unsafe.Pointer(funcPC(usleep_trampoline)), unsafe.Pointer(&usec))
}
func usleep_trampoline()

// go nosplit 
func usleep_no_g(usec uint32) {
	asmcgocall_no_g(unsafe.Pointer(funcPC(usleep_trampoline)), unsafe.Pointer(&usec))
}

func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32 {
	return libcCall(unsafe.Pointer(funcPC(sysctl_trampoline)), unsafe.Pointer(&mib))
}
func sysctl_trampoline()

// go:nosplit 
// go:cgo不安全参数
func fcntl(fd, cmd, arg int32) int32 {
	return libcCall(unsafe.Pointer(funcPC(fcntl_trampoline)), unsafe.Pointer(&fd))
}
func fcntl_trampoline()

// go:nosplit 
func nanotime1() int64 {
	var ts timespec
	args := struct {
		clock_id int32
		tp       unsafe.Pointer
	}{_CLOCK_MONOTONIC, unsafe.Pointer(&ts)}
	libcCall(unsafe.Pointer(funcPC(clock_gettime_trampoline)), unsafe.Pointer(&args))
	return ts.tv_sec*1e9 + int64(ts.tv_nsec)
}
func clock_gettime_trampoline()

// go:nosplit 
func walltime() (int64, int32) {
	var ts timespec
	args := struct {
		clock_id int32
		tp       unsafe.Pointer
	}{_CLOCK_REALTIME, unsafe.Pointer(&ts)}
	libcCall(unsafe.Pointer(funcPC(clock_gettime_trampoline)), unsafe.Pointer(&args))
	return ts.tv_sec, int32(ts.tv_nsec)
}

// go nosplit 
// go cgo:cgo不安全参数
func kqueue() int32 {
	return libcCall(unsafe.Pointer(funcPC(kqueue_trampoline)), nil)
}
func kqueue_trampoline()

// go go nosplit 
func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timespec) int32 {
	return libcCall(unsafe.Pointer(funcPC(kevent_trampoline)), unsafe.Pointer(&kq))
}
func kevent_trampoline()

// go:cgo\u unsafe\u args 
func sigaction(sig uint32, new *sigactiont, old *sigactiont) {
	libcCall(unsafe.Pointer(funcPC(sigaction_trampoline)), unsafe.Pointer(&sig))
}
func sigaction_trampoline()

// go:nosplit 
// go:cgo\u unsafe\u args 
func sigprocmask(how uint32, new *sigset, old *sigset) {
	libcCall(unsafe.Pointer(funcPC(sigprocmask_trampoline)), unsafe.Pointer(&how))
}
func sigprocmask_trampoline()

// go:nosplit 
// go:cgo\u unsafe\u args 
func sigaltstack(new *stackt, old *stackt) {
	libcCall(unsafe.Pointer(funcPC(sigaltstack_trampoline)), unsafe.Pointer(&new))
}
func sigaltstack_trampoline()

// 未在OpenBSD上使用，但必须定义。
func exitThread(wait *uint32) {
}

// go:nosplit 
func closeonexec(fd int32) {
	fcntl(fd, _F_SETFD, _FD_CLOEXEC)
}

// go:nosplit 
func setNonblock(fd int32) {
	flags := fcntl(fd, _F_GETFL, 0)
	fcntl(fd, _F_SETFL, flags|_O_NONBLOCK)
}

// 告诉链接器将在系统库中找到libc_*函数
// 但缺少libc_*前缀。所以，我们可以说“cgo导入动态libc\u getthrid getthrid”libc.so“

// go:cgo\u导入动态libc\u退出libc.so”libc.so“
// go:cgo\u导入动态libc\u getthrid getthrid”libc.so“
// go:cgo\u import\u dynamic libc\u thrkill thrkill”libc.so“

// go:cgo\u import\u dynamic libc\u mmap mmap”libc.so“
// go:cgo\u import\u dynamic libc\u munmap”libc.so“
// go:cgo\u import\u dynamic libc\u vised maddise”libc.so“

// go:cgo\u导入动态libc\u关闭libc.so“
// go:cgo\u导入动态libc\u读取”libc.so“
// go:cgo\u导入动态libc\u写入”libc.so“
// go:cgo\u导入动态libc\u管道2”libc.so“

// go:cgo\u导入动态libc\u写入”libc\u时钟gettime“libc.so”
// go:cgo\u import\u dynamic libc\u setitimer setitimer”libc.so“
// go:cgo\u import\u dynamic libc\u usleep usleep”libc.so“
// go:cgo\u import\u dynamic libc\u sysctl sysctl”libc.so“
// go:cgo\fcu import\u dynamic libc\u fcntl”libc.so“
// go:cgo\u import\u dynamic libc\u getpid getpid”libc.so“
// go:cgo\u import\u dynamic libc\u kill kill”libc.so“
// go:cgo\u import\u dynamic libc\u queue kqueue”libc.so“
// go:cgo\u import\u dynamic libc\u kevent kevent”libc.so“

// go:cgo\u import\u dynamic libc\u sigaltstack sigaltstack”libc.so“

// go:cgo\u import\u dynamic\u”libc.so“
